#ifndef __USER_HANDLE_H__
#define __USER_HANDLE_H__


#define USED_FLASH_DATA

#define HW_PALETTE_SUPPORT      1
#include "md_OSD.h"
#include "zdfl_core_mwui.h"

// Here is the page index defination
#define HOMEPAGE_IDX 0
#define SETUPPAGE_IDX 1


// Here is the ctrl index defination
#define IMAGE0_IDX 0
#define BTN1_IDX 1
#define BTN2_IDX 2
#define BTN3_IDX 3
#define BTN4_IDX 4
#define BTN5_IDX 5
#define BTN6_IDX 6
#define BTN7_IDX 7
#define BTN8_IDX 8
#define BTN9_IDX 9
#define BTN10_IDX 10
#define BTN11_IDX 11
#define BTN12_IDX 12
#define BTN13_IDX 13
#define IMAGE14_IDX 14
#define BTN15_IDX 15
#define BTN16_IDX 16
#define BTN17_IDX 17
#define BTN18_IDX 18
#define BTN19_IDX 19
#define BTN20_IDX 20
#define BTN21_IDX 21


/********************************************************
 *these parameters are defined for using for funciton like as ProcessMessage(),SendMesssage(),GetMessage()
 ********************************************************/
/* command type:CMD_IR,CMD_KEY,CMD_TOUCH,CMD_USER or other*/
typedef enum{
    CMDNULL = 0,
    CMD_IR,
    CMD_KEY,
    CMD_TOUCH,
    CMD_MOUSE,
    CMD_DEBUG,
    CMD06,
    CMD07,
    CMD08,
    CMD09,
    CMD0A,
    CMD0B,
    CMD0C,
    CMD0D,
    CMD0E,
    CMD0F,
    CMD_TIMER,
    CMD_USER,
    CMD_SYSTEM
}CMD_Map;


/*IR Param type:Up,Down,Left,Right,Menu,Select,Exit*/
enum
{
    KWUI_IR_UP,
    KWUI_IR_DOWN,
    KWUI_IR_LEFT,
    KWUI_IR_RIGHT,
    KWUI_IR_MENU,
    KWUI_IR_SEL,
    KWUI_IR_EXIT,
};


/*Keypad Param type:Up,Down,Left,Right,Menu,Select,Exit*/
enum
{
    KWUI_KEYPAD_UP,
    KWUI_KEYPAD_DOWN,
    KWUI_KEYPAD_LEFT,
    KWUI_KEYPAD_RIGHT,
    KWUI_KEYPAD_MENU,
    KWUI_KEYPAD_SEL,
    KWUI_KEYPAD_EXIT,
};


/*Mouse Param type:Move,LDown,LUp,RDown,RUp*/
enum
{
    KWUI_MOUSE_MOVE,
    KWUI_MOUSE_LDOWN,
    KWUI_MOUSE_LUP,
    KWUI_MOUSE_RDOWN,
    KWUI_MOUSE_RUP
};


/*Touch Param type:Down,Up*/
enum
{
    KWUI_TOUCH_DOWN,
    KWUI_TOUCH_UP,
    KWUI_TOUCH_MOVING,
    KWUI_TOUCH_MOVE_END,
    KWUI_TOUCH_NORMAL,
    KWUI_TOUCH_DISABLE,
    KWUI_TOUCH_SUBPAGE,
};


void Onbtn1Click(void);
void Onbtn2Click(void);
void Onbtn3Click(void);
void Onbtn4Click(void);
void Onbtn5Click(void);
void Onbtn6Click(void);
void Onbtn7Click(void);
void Onbtn8Click(void);
void Onbtn9Click(void);
void Onbtn10Click(void);
void Onbtn11Click(void);
void Onbtn12Click(void);
void Onbtn13Click(void);
void Onbtn15Click(void);
void Onbtn16Click(void);
void Onbtn17Click(void);
void Onbtn18Click(void);
void Onbtn19Click(void);
void Onbtn20Click(void);
void Onbtn21Click(void);


void OnHomePageTouchMoving(U16 px, U16 py);
void OnHomePageTouchMoved(U16 px, U16 py);
void OnSetupPageTouchMoving(U16 px, U16 py);
void OnSetupPageTouchMoved(U16 px, U16 py);

void OnButton17TouchMoving(LPUIPBUTTON button, U16 px, U16 py);
void OnButton17TouchMoved(U16 px, U16 py);

#define INIT_LOAD_SCRATCH_PAGE 0

extern CONST BITMAP SystemIcon[];
extern CONST UIControlIcon_struct IconShowOnCanvas[];
extern CONST FONTINFO System_Font[];
extern CONST FONTINDEX System_Font_Index[];
extern CONST UIControlString_struct StringShowOnCanvas[];
extern CANVAS User_Canvas[];
extern CONST UIControlRect_struct RectShowOnCanvas[];
extern CONST SCRATCH User_Scratch_Page[];


U16 ZGetImageID(U16 id, UIControlIcon_struct *icon);

void ZApp_Draw_Image_XY(U16 UICtrlID, UIControlIcon_struct * UIIcon, int x, int y);
void ZApp_Display_Image_XY(U16 bitmap_id, U8 canvas_id, U16 px, U16 py);
void InitCtrlValue(HUICTRL hCtrl);
void InitPageValue(HUICTRL page_id);
void *GetCtrlHandle(HUICTRL hCtrl);
void *GetPageHandle(HUICTRL page_id);
U16 ZCreatePage(U8 page_id);
void InitCoreTimer(DWORD loop_counter);
void ZAPPTimerRun();
void ProcessMessage(U8 msg_type, U16 msg_item, U16 param, U16 paral, U16 paran);
void SendMesssage(U8 msg_type, U16 msg_item, U16 param, U16 paral, U16 paran);
U16 GetMessage(msg_data_t * msg);
void ZUIRedrawCtrl(U16 ctrl_id);
void ZUIRedrawPage(U8 page_id);
void ProcessCtrlofPage(U16 page_id);
U8 ZGetCtrlValue(WORD ctrl_id);
U8 ZSetCtrlValue(WORD ctrl_id, U8 value, U8 mode);
void * ZGetInfoPtr(WORD ctrl_id);
void ZInit_App(int flag);
void ZPrintCtrlBarPos(WORD ctrl_id, int offsetx, int offsety, U16 fcolor, U16 bcolor);



#endif

